package com.hzw.saas.common.pay.enums;

import java.util.Objects;

public enum PayType {

    /**
     * "支付宝
     */
    ALI_PAY(1, "支付宝"),

    /**
     * 微信支付
     */
    WECHAT_PAY(2, "微信支付"),

    /**
     * 银联
     */
    UNION_PAY(3, "银联"),

    /**
     * 余额支付
     */
    BALANCE_PAY(4, "余额支付");

    private final Integer value;

    private final String text;

    public Integer value() {
        return value;
    }

    public String text() {
        return text;
    }

    PayType(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public static String text(Integer value) {
        for (PayType payType : PayType.values()) {
            if (Objects.equals(payType.value, value)) {
                return payType.text;
            }
        }
        return null;
    }

    public static PayType instance(Integer value) {
        for (PayType payType : PayType.values()) {
            if (Objects.equals(payType.value, value)) {
                return payType;
            }
        }
        return null;
    }
}
